# class Animal:
#     def __init__(self, colour, shape):
#         self.colour = colour
#         self.shape = shape
#
#     def day_eat(self):
#         print("吃饭")
#
# class Dog(Animal):
#     def __init__(self, colour, shape):
#         super().__init__(colour, shape)
#
#     def dog_eat(self):
#         print("狗的独特行为是狗叫")
#
# class Cat(Animal):
#     def __init__(self,colour, shape):
#         super().__init__(colour, shape)
#
#     def cat_eat(self):
#         print("猫的独特行为是猫叫")
#
# a1 = Dog("白色", "big")  # 获取子类的方法
# a1.day_eat()  # 子类的实例调用父类的方法
# a1.dog_eat()  # 子类的实例调用子类的方法
# a2 = Cat("黑色", "small")
# a2.day_eat()
# a2.cat_eat()
# print(a1.colour)
# print(a1.shape)
# print(a2.colour)
# print(a2.shape)
import math


# class Employee:
#     def __init__(self, name, age, salary):
#         self.name = name
#         self.age = age
#         self.salary = salary
#
#     def work(self):
#         print(f"{self.name}每天工作8小时")
#
#     def __str__(self):
#         return f"员工{self.name}"
#
# class Manager(Employee):  # 经理需要团队属性
#     def __init__(self, name, age, salary):  # 重写父类的构造方法
#         super().__init__(name, age, salary)
#         self.work_team = []
#
#     def manage_team(self):
#         print(f"{self.name}管理团队")
#         for name in self.work_team:
#             print(name)
#
#     def add_team_member(self, employee):  # 添加团队成员
#         self.work_team.append(employee)
#
# class Developer(Employee):
#     def __init__(self, name, age, salary, language):  # 重写父类的构造方法
#         super().__init__(name, age, salary)
#         self.language = language  # 增加编程语言属性
#
#     def show_language(self):  # 展示语言的方法
#         print(f"{self.name}用{self.language}编程")
# # 获取两个子类对象
# p1 = Manager('A', '20', '4000')
# p2 = Developer('B', '21', '5000', 'English')
# p3 = Developer('C', '25', '6000', 'Java')
# # 创建团队
# p1.add_team_member(p2)
# p1.add_team_member(p3)
# # 管理团队
# p1.manage_team()
# # 员工工作
# p1.work()
# p2.work()
# p3.work()
# # 展示语言
# p2.show_language()
# p3.show_language()

# class Shape:
#     def area(self):  # 计算图形面积
#         pass
#
# class Circle(Shape):
#     def __init__(self, r):
#         self.r = r
#
#     def area(self):
#         print(f"圆的面积是：{math.pi* self.r * self.r}")

# class Rectangle(Shape):
#     def __init__(self, long, width):
#         self.long = long
#         self.width = width
#
#     def area(self):
#         print(f"长方形的面积是：{self.long * self.width}")
#
# class OtherShape:
#     def needarea(self, shape):
#         shape.area()

# c1 = Circle(3)
# r1 = Rectangle(3, 4)
# s1 = OtherShape()
# s1.needarea(c1)
# s1.needarea(r1)

shapes = [Circle(3), Rectangle(3, 4)]
for shape in shapes:
    shape.area()
#
# class Payment:
#     def pay(self, amount):  # amount:支付金额
#         pass
#
# class CreditCardPayment(Payment):
#     def pay(self, amount):
#         print(f"刷卡支付{amount}元")
#
# class PayPalPayment(Payment):
#     def pay(self, amount):
#         print(f"支付宝支付{amount}元")
# # 多态状态下，使用相同的对象名，调用相同的方法，传入数据实现不同的行为
# def ues_payment(payment, amount):  # 支付对象， 支付金额
#     payment.pay(amount)
# # 创建支付方式对象
# cr = CreditCardPayment()
# pa = PayPalPayment()
# # 模拟支付
# ues_payment(cr, 100)
# ues_payment(pa, 200)













